import { Controller, Get, Post, Patch, Body, Param, Delete, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Limit } from '@common/utils/constants';
import { ShopCreateDto, ShopListDto, ShopUpdateDto } from './dto';
import { ShopService } from './shop.service';

@ApiTags('shop')
@ApiBearerAuth()
@Controller()
export class ShopController {
    constructor(private readonly shopService: ShopService) {}
    /**
     * 新增店铺表
     */
    @ApiOperation({ summary: '新增店铺表' })
    @Post('/shop/create')
    create(@Body() createShopDto: ShopCreateDto) {
        return this.shopService.create(createShopDto);
    }
    /**
     * 店铺表列表（query）
     */
    @ApiOperation({ summary: '店铺表列表（query）' })
    @Post('/shop/list')
    queryList(@Body() dto: ShopListDto) {
        return this.shopService.list(dto);
    }
    /**
     * 店铺表列表
     */
    @ApiOperation({ summary: '店铺表列表' })
    @Get('/shop/list')
    list(@Query() limit: Limit) {
        return this.shopService.list({ limit });
    }
    // @Get('/shop')
    // findAll() {
    //     return this.shopService.findAll();
    // }
    /**
     * 店铺表详情
     */
    @Get('/shop/details/:id')
    @ApiOperation({ summary: '某个店铺表信息' })
    @ApiResponse({
        status: 200,
        // description: 'The found record',
        // type: GetShopInfoResult,
    })
    details(@Param('id') id: number) {
        return this.shopService.findById(id);
    }
    /**
     * 修改店铺表
     */
    @Patch('/shop/update/:id')
    @ApiOperation({ summary: '修改店铺表信息' })
    update(@Param('id') id: number, @Body() updateShopDto: ShopUpdateDto) {
        return this.shopService.update(id, updateShopDto);
    }
    /**
     * 删除店铺表
     */
    @ApiOperation({ summary: '删除店铺表' })
    @Delete('/shop/remove/:id')
    remove(@Param('id') id: string) {
        return this.shopService.delete(+id);
    }
}
